small refactoring + tests for directives