SERVER-12949 Restore intermediate in-memory reduces, which are used to
keep the memory occupied by map/reduce small and spill extra large results
to disk.

Also adds a JS unit test to ensure this behaviour doesn't change
accidentally.

(cherry picked from commit acc47ab1b993d1abc295974200ffc57d98f4b80e)