fixed errors and failed tests