Add time grouping + tests