Added tests and made a couple of fixes on the library