Refactored some classes

Refactored for better understanding and for better unit test usage.