Add comprehensive test for the directory handler