Complete Ch 7 exercises: add tests, clean up error messages, etc