Use "test -d" instead of "ls".

We are interested in directory existence, not its content. Although I
did not performed any benchmarks, I believe, that "test -d" should be
more effective.
Check directory existence using "test -d" instead of "ls".
Merge pull request #54 from voxik/ls-to-test

Check directory existence using "test -d" instead of "ls".