added more tests and fixed some bugs