Refactoring + missing unit tests