Merge in fixes and cleanup from work on the custom loader testing.

This adds a bunch of code to host_fake and reworks the tests in
main_test to be more friendly to running with a custom module loader
that we could use to run the tests against a fake host without needing
a totally fake unittest loader.

This does not merge in the custom module loader yet because I'm not
entirely happy with that code, and it doesn't work in Python 3.