refactorings and additional unit testing
refactorings and more unit tests