Fix regression of challenge 4
Add tests for challenge 6