added a few more tests and did minor refactoring