implement merge; add tests