refactoring the tests from chapter 5