Add new tests and repair few bugs.