Improved checking of hex argument in lookup

* Checks that hex argument is more or equal to 4 characters and less
  than or equal to 40 characters.