Fixed tests and broken code