added more tests and some fixes