Move context assignment to only where it is required
Merge pull request #3139 from mkoistinen/move_context_assignment

Move context assignment to only where it is required