Oliviers patch

Minimal changes to compile and run tests
Andys patch

Applied on top of Olivier's, this aligns it with the spec