Fix #2

Apply the proposed fix and add an integration test.

Signed-off-by: Clement Escoffier <clement.escoffier@gmail.com>