Various improvements and overall stability to current tests

The changes mostly involve adding an afterEach handler to ensure state
if cleaned up after such as an open session.

One subtle change in the session is that data is fetched when the
session is opened, rather than waiting until the session is started.

In addition, the models/query and ui/templates modules have been
ported to JavaScript.

Signed-off-by: Byron Ruth <b@devel.io>