refactor out sorting tests