Corrected a lot of small problems.
Added more tests.