Type fixes and a Junit test for them.

Signed-off-by: Atheriel <atheriel@gmail.com>