First try at the code and tests