Fix bracket paths

There was a serious bug where directories with brackets in the name were not getting traversed correctly.
I created some unit tests and fixed the bug.  I was tempted to get rid of most of the Dir[] code and use Dir.entries, but I'm pretty sure I couldn't replicate functionality.  My tests say this gets everything I care about without breaking any of your stuff.

An unrelated fix in this branch is there was a bug in your test_maxdepth_file that was causing the tests to fail on my machine, so my fix for that is in here too.