Added functions and tests