Various unit tests fixes.

The patch is to fix some test failures found.