updated tests and minor code refactoring