Stub filesystem side effects in unit tests

We still had a few unit tests touching the filesystem. This commit
changes the import style of several files, and adds some patches in
BaseUnitTestCase to guard against use of various methods that touch
the filesystem.