add a bunch of new tests and fix bugs