Task 6 with tests