Added code and tests from Section 5.2
Code and tests from section 5.3