Context refactored to MapContext, ReduceContext, with tests