Add UnitTests, Fix bugs.