fixed errors & added test