Refactor out remove_sh_key() function

Add test for remove_sh_key() function