Fixed key format check

Fixes #600.