tests and methods for changing key state; added key_histories table with tests