Test consistency

A collection of fixes to tests to improve their consistency, and some minor speed improvements.