Refactoring
Additional documentation and tests