Add tests and fix.