Exercise 6: Implemented the compose function with test.