Added some tests and fixed a small bug

What do you think of this approach to testing? It is fairly high-level. Perhaps some real unit tests might also be desirable but I think this sort of "functional" testing might be appropriate. I also fixed a small bug. npm is required for development because bower doesn't have stuff like karma-mocha.