Added tests for several functions, fixed some bugs the tests made visible