2365 fix failed multipart process leak

Test is added in a separate commit to make verifying the fix easier - the two commits will be squashed together before merge.

COUCHDB-2365