Railroad companies in carrying or transporting animals shall not permit them to be confined in cars for a longer period than forty-eight consecutive hours without unloading them for rest, water, and feeding for a period of at least two consecutive hours, unless prevented from so unloading them by unavoidable accident. In estimating such confinement, the time during which the animals have been confined without such rest on connecting roads from which they are received shall be included. Animals so unloaded shall, during such rest, be properly fed, watered by the owner or person having the custody of them, or in case of his or her default in so doing, then by the railroad company transporting them, at the expense of said owner or person in custody thereof, and said company shall in such case have a lien upon such animals for food, care, and custody furnished, and shall not be liable for such detention of such animals. If animals are transported where they can and do have proper food, water, space, and opportunity for rest, the foregoing provision in regard to their being unloaded shall not apply. Violators of this section shall be punished by fine not exceeding one thousand dollars per animal.