Fix logic for logging to destination directory and add tests for it

Closes #83