Added some utility functions and their tests.