diff --git a/mixpanel_jql/query.py b/mixpanel_jql/query.py
index 919894f..768da83 100644
--- a/mixpanel_jql/query.py
+++ b/mixpanel_jql/query.py
@@ -394,19 +394,19 @@ class JQL(object):
         return jql
 
     def group_by(self, keys, accumulator):
-        if not isinstance(keys, (tuple, set, list)):
-            keys = [keys]
-        jql = self._clone()
-        jql.operations += ("groupBy([%s], %s)"
-                           % (", ".join(_f(k) for k in keys), _f(accumulator)),)
-        return jql
+        return self._group_by(False, keys, accumulator)
 
     def group_by_user(self, keys, accumulator):
+        return self._group_by(True, keys, accumulator)
+
+    def _group_by(self, user, keys, accumulator):
         if not isinstance(keys, (tuple, set, list)):
             keys = [keys]
+        if not isinstance(accumulator, Reducer):
+            accumulator = _f(accumulator)
         jql = self._clone()
-        jql.operations += ("groupByUser([%s], %s)"
-                           % (", ".join(_f(k) for k in keys), _f(accumulator)),)
+        op = "groupByUser" if user else "groupBy"
+        jql.operations += ("%s([%s], %s)" % (op, ", ".join(_f(k) for k in keys), accumulator),)
         return jql
 
     def query_plan(self):

diff --git a/tests/test_transformations.py b/tests/test_transformations.py
index f66c218..e7f3dfc 100644
--- a/tests/test_transformations.py
+++ b/tests/test_transformations.py
@@ -63,6 +63,12 @@ class TestGroupTransformations(unittest.TestCase):
             'function main() { return Events({}).'
             '%s([e.a, e.b, e.c], e.properties.some_accessor); }' % expected_function)
 
+        self.assertEqual(
+            str(grouper([
+                raw('e.a'), raw('e.b'), raw('e.c')], Reducer.count())),
+            'function main() { return Events({}).'
+            '%s([e.a, e.b, e.c], mixpanel.reducer.count()); }' % expected_function)
+
         # Non iterable key.
         self.assertEqual(
             str(grouper(raw('e.a'), raw('e.properties.some_accessor'))),

mixpanel_jql.exceptions.InvalidJavaScriptText
Hi, first of all thanks for this project!

I'm trying to run the first example and I'm getting:
`mixpanel_jql.exceptions.InvalidJavaScriptText: Must be a text type (str, unicode) or wrapped as raw(str||unicode)`

I'm runnning Python 3.6.5 on Ubuntu 18.04
tests/test_transformations.py::TestGroupTransformations::test_group_by tests/test_transformations.py::TestGroupTransformations::test_group_by_user
tests/test_transformations.py::TestAccessorOnlyTransformations::test_filter tests/test_transformations.py::TestAccessorOnlyTransformations::test_map tests/test_transformations.py::TestAccessorOnlyTransformations::test_reduce tests/test_transformations.py::TestAccessorOnlyTransformations::test_sort_asc tests/test_transformations.py::TestAccessorOnlyTransformations::test_sort_desc