don't clear attachments when points to same reference

If an error was thrown, and the IN message has the same reference for attachments as OUT message, they shouldn't be cleared.