Add reduce function to Collection

Added a reduce method (also helps towards #2155). Also added a test for Collection::map() while I was in there.