Unit tests

https://www.pivotaltracker.com/story/show/82225792

Currently waiting for https://www.pivotaltracker.com/story/show/82225934 to finish this.