reordered function to be gaurd then functionality.
When returning an error return nil as the return value not an empty value of the correct type.
rewrite and extend graph path test to be easier to read and to show a successful graph traversal.