fixed serious bug where test set was sorted incorrectly