added director.js, updated tests, refactoring