adding more tests and correcting some bugs