added more tests and improvements