added test cases and support for keygroups