Use indexes to fetch keys.
Fix wrong iv test to account for new form of iv.