Why this transaction is valid?
The transaction is valid. This golang code gives the correct result.

You need to HASH160 51, not 1.

Additionally, make sure you run the hash on 0x51, not "51" or int(51).