Replace merge_by_* and is_intersection with merge and merge_opt

The tests for merge_by_intersection pass with merge.