Fix for FastForward detach issue + test.

This is the fix described in the comments of https://github.com/libgit2/libgit2sharp/pull/608/files.