Fixed bugs - tests now passing