Modified app.js to make it more testable

Moved a statement that use “document” object to index.html. This was
necessary to make app.js more testable.