Fix tests by introducing stable sort. #80