add tests for bin trees
improve performance of replaceWith