Refactor setup and teardown