fix integration test, return last error but reset it immediately