Fix bug in listDirectory regarding nested dirs