Some logging/error handling improvements
Add licence header
Update test file in fixtures
Remove createAttachment after review

Move attachment copying out of database transaction
and into new PreparedAttachment constructor