find best k algorithm and tests