Added new tests and improvements.

All 51 tests pass.