Improve es5 strict mode compatibility.

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

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