Fixed checksum checking code
Added more tests and checks