Fixed several test code bugs.

Fixes #329, #330, #331, #332, #333, #334.
Fixed a Firefox result, and recompiled typescript.html
Merge pull request #335 from webbedspace/bugfixes

Fixed several test code bugs