Fix errors when accessing a 40-char long ref

This pull request addresses the two issues mentioned in Issue #82, i.e. the handling of 20/40-character refs in Repo.__getitem__, and the type of exception thrown by hex_to_sha() in the event of being passed an invalid string.