Fix code to match tests