Some work on cleaning up tests.
Clean up some tests.
Break out tests into their subsystem implementation files.
Merge branch 'master' into userspace