Does the same behaviour also occur when you replace the following line of JavaScript code:
merge.context.sections["Content"].addHeader("X-SMTPAPI", JSON.stringify(headerObj));
with the following?
merge.template.contexts.HTML_EMAIL.sections["Content"].addHeader("X-SMTPAPI", JSON.stringify(headerObj));
Info: Notice the difference? The start of the line of JavaScript code changed from merge.context.sections to merge.template.contexts.HTML_EMAIL.sections.