There were two problems here.
* The $msgdata->fullmessage was always formatted as HTML even if the
$msgdata->fullmessageformat was set to the original template's format.
* The plain text part of the emailed message contained HTML code.
The patch makes sure that the original template is always formatted into
HTML and then converted to plain text before setting the text/plain
multipart of the sent email.
Expanded the unit tests to ensure unnecessary events are not
saved in the DB and altered existing tests so they pass with
the introduction of this feature.
An event that has already contributed to a notification should not contribute to another notification for the same subscription.
This needs to be done so we do not overwhelm the user.