fixed bugs and tests from last commit