Solution with tests