Fixed errors in hash1 calculation, also added a testcase which would have found the error