Add support for multiple grouping and aggregation

Includes 3 new tests.