Workaround for named nested functions.

I have trouble using nested function declarations inside validate_doc_update, because every "function helper(doc)" is stripped down to "function(doc)" and syntax is rendered invalid. My suggestion would be to apply substitution only to functions at the beginning of a line. I mean who on earth would write "[space][space][space][space]function map(doc) {"???

Cheerio
Oscar