First version of code with tests.