Reorganizing utils.reduce and tests