Tests on median pivots and backing up the tree in NN search, bugfixes to boot