Add group by clause class
Refactor dependencies via injection & add unit tests