Added another batch of tests and fixed a few bugs