added 2 test, minor refactoring