Small code simplification

Signed-off-by: Julien Danjou <julien@danjou.info>
Add test case for issue #137

Signed-off-by: Julien Danjou <julien@danjou.info>