Extended any_of test to include exceptional invalid state case.