This patch enables test failure report when result.failed is set, and make tests more robust against environment differences.