Fix code + tests

Signed-off-by: Alexander Cogneau <alexander.cogneau@hotmail.be>