First version of the function and tests.