gen_key test coded