fix date comparison bug

Same as before, restored due to merge error. Also check for working dir
existence