Fixed tests and bug found doing so