Fixed unit tests, and minor improvements.