Tests and fixes

The library was pretty broken, so I fixed the methods and added some tests.