Add merge functionality, tests