backport changes to fix tests