(#14872) PMT respect environment's module path

This is a second version of a patch which fixes the
Puppet::ModuleTool#set_option_defaults method such that it respects
the specified environment (if any) when determining the default
value for the --target-dir (the modules install directory) option.
The patch overhauls the entire method in the process to make it more
readable, and it also updates relevant unit tests and adds a pair
of new acceptance tests (which in contrast to the original patch
version don't depend on augeas).