Backported Gradle test execution fixes from master/2.2.X