code and some (incomplete) test cases for file dispatcher