refactored code to use setup and teardown methods