solved second problem with tests