added mkdir when directory is missing
updated Test to test for directory creation