Tweak merge method and add tests.