Added functions and unit tests