Fixes to tests.
Added comments to explain the way some things work.