Add more tests and fix a bug in from_code.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>