Fix 4.21. Improve key detection. Don't crash the client a unit test fails.