Test if dir exists first