First implementation, with tests