Fixed broken unit tests and broken code.