performance promotion in handle nested dirs

1. remove sub directories to avoid find same files twice.
2. add unit test file.