fixed failing code and updated tests