Refactor setup/teardown scripts