added more tests, fixed some bugs