Fix some bugs in the function exporting.

Thanks to azakai from #emscrpiten on irc.mozilla.org.