When using both headers and a body in a result, headers are written after the body.
However, headers may not be set once the entity body has started to be written. This commit introduces a test + fix.