Conform response for grouping query to api design

@abersager
@maxfliri
Add sort by to grouped query

@pbadenski
@robyoung
Add limit to grouped query

@pbadenski
@robyoung
Switch order of nesting in periodic grouped query

@pbadenski
@robyoung
Extract and simplify group integration tests

They were getting a bit disjointed and hard to follow. This pulls them
out into their own class with a common fixture used across all the
tests.
Refactor grouping and repo response format

This makes both grouping functions in database.Repository use the same
code. It also changes the output to be nested lists and therefore allow
sorting.
Add sorting to multi group query

@pbadenski
@robyoung
Add limit to multi group query

@pbadenski
@robyoung
Add limit to period query

@pbadenski
@robyoung
Don't allow sorting of periodic queries

@robyoung
@pbadenski
More descriptive error messages

@robyoung
@pbadenski