Moves template context related code to new context module