Add more tests and fix a couple of things