Add tests for grouping functions