Fixed sorting test bugs