Listing 9.7 with tests passing as expected.