Add tests

Hey look, some tests! (builds atop my previous pull request, though there shouldn't be many conflicts between the two)