Attachment fixes

Fixes almost all the issues mentioned in #344.

I didn't touch `Replacing an attachment seems to not create any revisions.` because I don't completely understand the intention behind the  `if self.can_moderate()` check.