Add tests for group sorting