added test case for rotating log files
fixing variable scopes
automatically create the directory