rewrite and enhance mkdir function in filetools.py, add thorough unit test for it