Refactor to allow unit testing using Jasmine and Karma and CI using Travis-ci.