Added 3 more tests, found a few bugs and fixed them.