(PUP-3511) refactor Application.run for reuse

Extract a small chunk of code from Puppet::Application.run into its own
method so that it can be reused.  This code is currently duplicated in
Puppet Server; the introduction of this new `reset_environment_context`
method enables the replacement of the duplicated code in Puppet Server
with a call to this new method.
A documentation comment for the method with yardoc that explains the type of the param, and the tag `@api private` would be really helpful. Something like:
"Pushes a Puppet Context configured with a remote environment for an agent (one that exists at the master end), and a regular environment for other modes. The configuration is overridden with options from the command line before being set in a pushed Puppet Context".