Fix compilation issue and add some tests.