Refactored config and tests

Also touched some other spots for pep8 correctness.