Adding unit test coverage for sorting bug