fixed bugs in another branch with better tests merged