Tweaks that make 'master' closer to '4.0.x'

Mostly tweaks related to test code, removes unnecessary differences between master and 4.0.x branches.