Refactored tests as per exercises in chapter 5