bug fixes and tests for aes