Refactor tests to use before and after