More bugfixes for merge
Added unittests for merge
Added some more tests