Fix usage of 'expect_fail' in T2507
Add test case for #8184