mock listdir properly, fix a bug