Fixed broken tests and fixed a bug.