Fix crash where file/directory name is a number

I came across this bug whilst trying to delete a directory with a number (e.g. '123') as its directory name on OS X. I have also amended the tests to test for this bug. I have not tested this on other systems.
don't change the file mode (see above): `100644 → 100755`