Fixed up tests and bugfix till they work.