solved chapter 5 exercises - mostly adding and refactoring tests