added a bunch of tests, fixed a couple of associated errors