Added some tests + fixes