Add callback to ready()

Fix require.js example bugs, and add tests/docs for the requirejs context.