More additions to the unit tests, and made some changes to fix bugs