refactored code structure and init unit tests