CRM-15333 - Fix multiple-merges of hook-results

This is a resubmission of https://github.com/civicrm/civicrm-core/pull/4166
which targets v4.5 and adds a unit-test.