add some tests and fix bug in toTest sorting