1. Fixed a bug that meant we continued to use state related to the realm where an object was first created, even though a sub-realm had been installed.
2. Added lots more spec tests around realm and sub-realm installation and use.
3. Cleaned up the existing spec tests.
4. Simplified the code, and pulled out the code used to define the require-function passed to defined modules to make things clearer.