Fixed bugs in insertAndSplit

Also added another test case