Refactor to use require.js (tests not working yet)