Added some library functions, including unit tests