Directory test should be extended for extreme cases (1 file) or (1 dir) which may fail in scan operations.