Creation of a random key HDB entry takes 3 updates, not one. Instead of hard-coding this magic count, wait for the appearance of the expected entry with no "invalid" flag among its attributes.