More intelligent disabling of printing in tests