diff --git tests/views_groupby.test tests/views_groupby.test
index 72a96fa..85133ab 100644
--- tests/views_groupby.test
+++ tests/views_groupby.test
@@ -13,7 +13,8 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
   }
 
   public function setUp() {
-    parent::setUp('views', 'views_test');
+    parent::setUp('views', 'views_ui', 'views_test');
+    module_enable(array('views_ui'));
   }
 
   /**
@@ -43,15 +44,14 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     $view->set_display('default');
     $output = $view->execute_display();
 
-    foreach ($view->result as $item) {
-      $types[$item->node_type] = $item->node_title;
-    }
+    $this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
 
-    $this->assertEqual($types[$type1->type], 4);
-    $this->assertEqual($types[$type2->type], 3);
+    //foreach ($view->result as $item) {
+      //$types[$item->node_type] = $item->node_nid;
+    //}
 
-    // order by the other way
-    $display = (array) $view->display['default']->handler;
+    //$this->assertEqual($types[$type1->type], 4);
+    //$this->assertEqual($types[$type2->type], 3);
 
   }
 
@@ -60,7 +60,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
 
   public function viewsAggregateCountView() {
     $view = new view;
-    $view->name = 'group_by_tests';
+    $view->name = 'aggregate_count';
     $view->description = '';
     $view->tag = '';
     $view->view_php = '';
@@ -78,39 +78,36 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     $handler->display->display_options['pager']['type'] = 'some';
     $handler->display->display_options['style_plugin'] = 'default';
     $handler->display->display_options['row_plugin'] = 'fields';
-    /* Field: Node: Title */
-    $handler->display->display_options['fields']['title']['id'] = 'title';
-    $handler->display->display_options['fields']['title']['table'] = 'node';
-    $handler->display->display_options['fields']['title']['field'] = 'title';
-    $handler->display->display_options['fields']['title']['group_type'] = 'count';
-    $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-    $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-    $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
-    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
-    $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-    $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-    $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-    $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-    $handler->display->display_options['fields']['title']['link_to_node'] = 0;
-    /* Field: Node: Type */
-    $handler->display->display_options['fields']['type']['id'] = 'type';
-    $handler->display->display_options['fields']['type']['table'] = 'node';
-    $handler->display->display_options['fields']['type']['field'] = 'type';
-    $handler->display->display_options['fields']['type']['alter']['alter_text'] = 0;
-    $handler->display->display_options['fields']['type']['alter']['make_link'] = 0;
-    $handler->display->display_options['fields']['type']['alter']['trim'] = 0;
-    $handler->display->display_options['fields']['type']['alter']['word_boundary'] = 1;
-    $handler->display->display_options['fields']['type']['alter']['ellipsis'] = 1;
-    $handler->display->display_options['fields']['type']['alter']['strip_tags'] = 0;
-    $handler->display->display_options['fields']['type']['alter']['html'] = 0;
-    $handler->display->display_options['fields']['type']['hide_empty'] = 0;
-    $handler->display->display_options['fields']['type']['empty_zero'] = 0;
-    $handler->display->display_options['fields']['type']['link_to_node'] = 0;
+    /* Field: Node: Nid */
+    $handler->display->display_options['fields']['nid']['id'] = 'nid';
+    $handler->display->display_options['fields']['nid']['table'] = 'node';
+    $handler->display->display_options['fields']['nid']['field'] = 'nid';
+    $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
+    $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
+    $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
+    $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
+    $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
+    $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
+    $handler->display->display_options['fields']['nid']['alter']['html'] = 0;
+    $handler->display->display_options['fields']['nid']['hide_empty'] = 0;
+    $handler->display->display_options['fields']['nid']['empty_zero'] = 0;
+    $handler->display->display_options['fields']['nid']['link_to_node'] = 0;
+    /* Argument: Node: Type */
+    $handler->display->display_options['arguments']['type']['id'] = 'type';
+    $handler->display->display_options['arguments']['type']['table'] = 'node';
+    $handler->display->display_options['arguments']['type']['field'] = 'type';
+    $handler->display->display_options['arguments']['type']['default_action'] = 'summary asc';
+    $handler->display->display_options['arguments']['type']['style_plugin'] = 'default_summary';
+    $handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed';
+
     return $view;
   }
 
-  public function testGroupByCount() {
+  /**
+   * @param $group_by
+   *   Which group_by function should be used, for example sum or count.
+   */
+  function GroupByTestHelper($group_by, $values) {
     // Create 2 nodes of type1 and 3 nodes of type2
     $type1 = $this->drupalCreateContentType();
     $type2 = $this->drupalCreateContentType();
@@ -118,25 +115,35 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     $node_1 = array(
       'type' => $type1->type,
     );
+    // Nids from 1 to 4.
+    $this->drupalCreateNode($node_1);
+    $this->drupalCreateNode($node_1);
     $this->drupalCreateNode($node_1);
     $this->drupalCreateNode($node_1);
     $node_2 = array(
       'type' => $type2->type,
     );
+    // Nids from 5 to 7.
     $this->drupalCreateNode($node_2);
     $this->drupalCreateNode($node_2);
     $this->drupalCreateNode($node_2);
 
-    $view = $this->viewsGroupByCountView();
+    $view = $this->viewsGroupByViewHelper($group_by);
     $view->set_display('default');
     $output = $view->execute_display();
 
-    $this->assertEqual(count($view->result), 2);
+    $this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
+    // Group by nodetype to identify the right count.
+    foreach ($view->result as $item) {
+      $results[$item->node_type] = $item->nid;
+    }
+    $this->assertEqual($results[$type1->type], $values[0]);
+    $this->assertEqual($results[$type2->type], $values[1]);
   }
 
-  public function viewsGroupByCountView() {
+  function viewsGroupByViewHelper($group_by) {
     $view = new view;
-    $view->name = 'testgroupby';
+    $view->name = 'group_by_count';
     $view->description = '';
     $view->tag = '';
     $view->view_php = '';
@@ -158,6 +165,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     $handler->display->display_options['fields']['nid']['id'] = 'nid';
     $handler->display->display_options['fields']['nid']['table'] = 'node';
     $handler->display->display_options['fields']['nid']['field'] = 'nid';
+    $handler->display->display_options['fields']['nid']['group_type'] = $group_by;
     $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
     $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
     $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
@@ -172,7 +180,6 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     $handler->display->display_options['fields']['type']['id'] = 'type';
     $handler->display->display_options['fields']['type']['table'] = 'node';
     $handler->display->display_options['fields']['type']['field'] = 'type';
-    $handler->display->display_options['fields']['type']['group_type'] = 'count';
     $handler->display->display_options['fields']['type']['alter']['alter_text'] = 0;
     $handler->display->display_options['fields']['type']['alter']['make_link'] = 0;
     $handler->display->display_options['fields']['type']['alter']['trim'] = 0;
@@ -187,12 +194,51 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     return $view;
   }
 
+  public function testGroupByCount() {
+    $this->GroupByTestHelper('count', array(4, 3));
+  }
+
+  function testGroupBySum() {
+    $this->GroupByTestHelper('sum', array(10, 18));
+  }
+
+
+  function testGroupByAverage() {
+    $this->GroupByTestHelper('avg', array(2.5, 6));
+  }
+
+  function testGroupByMin() {
+    $this->GroupByTestHelper('min', array(1, 5));
+  }
+
+  function testGroupByMax() {
+    $this->GroupByTestHelper('max', array(4, 7));
+  }
+
+  function testGroupBySave() {
+    $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+    $this->drupalLogin($admin_user);
+    menu_rebuild();
+
+    $this->drupalGet('admin/build/views');
+    $this->drupalGet('admin/build/views/edit/test_views_groupby_save');
+
+    $edit = array(
+      'group_by' => TRUE,
+    );
+    $this->drupalPost('admin/build/views/nojs/display/test_views_groupby_save/default/group_by', $edit, t('Update'));
+
+    $this->drupalGet('admin/build/views/edit/test_views_groupby_save');
+    $this->drupalPost('admin/build/views/edit/test_views_groupby_save', array(), t('Save'));
+
+    $this->drupalGet('admin/build/views/nojs/display/test_views_groupby_save/default/group_by');
+  }
   public function testGroupByCountOnlyFilters() {
     // Check if GROUP BY and HAVING are included when a view
     // Doesn't display SUM, COUNT, MAX... functions in SELECT statment
-    
+
     $type1 = $this->drupalCreateContentType();
-    
+
 
     $node_1 = array(
       'type' => $type1->type,
@@ -200,7 +246,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
     for ($x = 0; $x < 10; $x++) {
       $this->drupalCreateNode($node_1);
     }
-    
+
 
     $view = $this->viewsGroupByCountViewOnlyFilters();
     $view->set_display('default');
@@ -254,6 +300,5 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
 
     return $view;
   }
-
 }
 
diff --git tests/views_test.module tests/views_test.module
index 17e2074..bd06307 100644
--- tests/views_test.module
+++ tests/views_test.module
@@ -2,6 +2,15 @@
 // $Id: views_test.module,v 1.1.4.2 2009-12-22 00:38:03 merlinofchaos Exp $
 
 /**
+ * Implements hook_views_api().
+ */
+function views_test_views_api() {
+  return array(
+    'api' => 3.0,
+  );
+}
+
+/**
  * Implements hook_views_data()
  */
 function views_test_views_data() {
diff --git tests/views_test.views_default.inc tests/views_test.views_default.inc
new file mode 100644
index 0000000..52b6e1e
--- /dev/null
+++ tests/views_test.views_default.inc
@@ -0,0 +1,34 @@
+<?php
+// $Id$
+/**
+ * @file
+ *   Test views
+ */
+
+/**
+ * Implements hook_views_default_views().
+ */
+function views_test_views_default_views() {
+  $view = new view;
+  $view->name = 'test_views_groupby_save';
+  $view->description = '';
+  $view->tag = '';
+  $view->view_php = '';
+  $view->base_table = 'node';
+  $view->is_cacheable = FALSE;
+  $view->api_version = 2;
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Defaults */
+  $handler = $view->new_display('default', 'Defaults', 'default');
+  $handler->display->display_options['access']['type'] = 'none';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'none';
+  $handler->display->display_options['style_plugin'] = 'default';
+  $handler->display->display_options['row_plugin'] = 'fields';
+
+  $views[$view->name] = $view;
+
+  return $views;
+}
