fixing minor bugs and passing all test