Add functions and tests