cleaned up GroupByScan and added tests