Added proper error reporting and a nice stacktrace.
Further improvements for the test framework.
Modify some more tests for emscripten.