added more tests and fixed more bugs