Update templates code to Jasmine test suite version 2.0.

Also, introduce a new waitsFor function which returns a Promise to execute
asynchronous callbacks.