Initial unit tests

This adds a few unit tests. This is primarily just an effort to get the ball rolling, and to teach myself how to do testing in emacs. 

I had to change a few function signatures to make testing easier, but I generally view this as healthy. Hopefully I haven't broken anything.