implement and test tuple merging