Automated testing, fixes #14

Somewhat hacky, but stable. Needs squashing.

Please comment :)