Add more tests and fix broken found while writing tests.