Added unit test for insertion, fixed minor bugs