Checking for valid closure now throws an instance of \InvalidArgumentException on failure.