Added test.js and fixed an undefined error