[PD-452] State fix for master

This is the exact same fix as #844, but applied against master. All tests except those dealing with authorize.net pass, which are expected failures which existed before this patch.