Deduplicate the cipher setup that was identical for all tests for each cipher.
Pull the code shared between chacha and gcm into generic functions.