Stop errors when attachment file is nil

Probably one for @floppy to review on Monday, but this seems to work. The tests I'm not quite sure about though. Could probably be
 a bit more rigorous (I never really have got my head around mocks).