Backport some missing test logic