Added transaction contract checks
Fixed calculating end prefix for key length 1