adds option to pass a function to use for merging data.
update tests