Apply the function against a set of arguments. Test the
expected argument against the result.
Return null if the arguments were invalid.
If 'expected' was not null and matched the result, return 'expected'.
If 'expected' was not null and did not match, return null;
Otherwise, return the result.