rewrite to separate tests for key and ctext