Update tests and code with chapter 4 learnings