Added snapshot & restore functions to make test cleanup easier

Needed so that tests against global config can change it without polluting later tests.