Fixed bugs and one broken test