test 'group by' logic