Emit change events when attachments are changed.
Added unit tests for the events.