Fix bugs that discovered by the unittest

Signed-off-by: TAKAHASHI Minoru <takahashi.minoru7@gmail.com>