fixed mutate+merge bug elasticsearch/logstash#1911 and added merge specs

Originally from https://github.com/elasticsearch/logstash/pull/1912