More unit tests and calculation fixes.