Made test more robust for different sortings on different platforms.