Solution and tests for Exercise 1.8