Unit tests and structure rework to make unit tests possible