change code position, and append test code of retrieve_id_by_type

Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>