Add test for knn classifier, fix a couple uncovered bugs