Added Tests, fixed some errors