Added input sanitation and more tests.