Added QUnit tests for stateless.js and fixed a bug with state init.