Added tests and fixed a couple things
Function now uses library version. Verified that there is no difference.