some code re-shuffling and first simple unit test