Added some tests and fixed errors