Refactor sorting tests