cleaned up MergeTable and added tests