Added more robust test for AES counter uniqueness
Crypto code cleanup and test improvements.