Check if key's len is valid or not.

fixes #451