fixes 773cd61 that is forgotten to return code, and add test code

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