finished chapter 1. added tests.