add map/reduce and tests