Improve missing file test to verify contents of file
Only add file on stream_close() when repo is dirty

Fixes #17