First revision with unit tests working