Move method 'merge' into separate class.
Add test for 'merge'.