Swap out the user prefs when running tests.

Fix for #7054. Note that the exception that appears in the console when running the tests is separate: #7161 

This should prevent tests that run in the specrunner window from clobbering
user-level prefs.

cc @redmunds