Unittest improvement

Hi - just a few minor changes/fixes to the unit tests. See commit messages for details. Kindly review.