Every such person, company or corporation owning or operating such railroad shall be liable for all damages sustained in the injury or killing of stock in any manner by reason of the failure of such person, company or corporation, to construct and maintain such fence or such crossing or cattle guard; but when such fences, crossings and guards have been duly made, and shall be kept in good repair, such person, company or corporation shall not be liable for any such damages, unless negligently or unlawfully done.