Add tests to the functions.
Updated code comments