Made sorting tests more robust