fixed Tests & cleaned some code