Add mergeDoubles function and tests.