Fix groupBy bugs

Updating test case