Adding tests and cleaning up a bunch