MDL-44257 message: check if the attachment exists before remove it

Credit goes to Mark Nielsen, thanks.
MDL-44257 message: added test to make sure the stored file still exists