Added some tests + fixed some bugs.