Small refactoring and new cool unit tests