Fix bugs and add tests for reductions with non-DataArray output