fix bugs that were catched in the test