Strip cwd from paths before hashing

I have altered the change proposed in issue #517 so that only strips the
cwd when it is a path passed in for hashing. Tests included.