directory encoder with tests