fix exercise 16.3 16.4

Add a test for exercise 16.3.
A better solution for exercise 16.4.