Formatting cleanup, fix test, add new test, and cleanup safely after test run