Second argument of merge overwrites its first argument except if second argument has NaNs (in this case first argument takes precedence). This commit reverts fd7476e6 and adds a new unit test. (cherry picked from commit c5b190d8)