improve length calculation for keywords.
assert keyword format.