A new law has been passed which introduces unlimited fines for owners of dogs which attack farm animals in "livestock worrying" incidents.