Wrote and fixed lots of tests

Random fact: This entire branch was done in the browser, using Github as a file editor and Travis as a builder/tester.