Unit tests have been improved. Some bugs have been fixed.