Fixes and improvements to the tests suite

Fixes and improvements to the tests suite