Fix Mako templates to always use updated request context

Fixed the edX middleware to lazily create request context for Mako templates, so that it is based on any changes made to the request object. 

Without this change, Mako templates for the courseware were rendered with the original user, rather than the user that had been updated by the courseware view. This had two side effects:
1. It defeated the ```prefetch_related``` call for the user's groups so ```has_access``` was not optimized
2. It defeated the preview's masquerade capability, so the Mako template always rendered the staff view, e.g. the "Instructor" tab was not hidden.

Added a Bok Choy test that verifies that the "Instructor" tab is correctly hidden when a staff member is viewing the course as a student.

Reviewers: @cpennington @dmitchell 
FYI: @ormsbee @adampalay @cahrens
Thanks, @cpennington. I went back and forth on this, and I landed here in order to have a consistent context for templates (which is how things work today). The code that updates the request is (currently) always before any template rendering, so it seemed like this might be a good compromise. However, it is certainly simpler to just generate a new one every time, so I'll change it if you think that's better.