Improve es5 strict mode compatibility.

In es5 strict mode "function" could be only top-level statements.