function fixes: implement @expected_error and fix double invocation for unexpected returns.