Remove duplications and fix tests.