Section 41. The defendant in an action for rescuing beasts distrained or impounded shall not be allowed to allege or give in evidence the insufficiency of the fences or any other fact or circumstance to show that the distress or impounding was illegal, but if there is such ground of objections to the proceedings he may avail himself thereof in an action of replevin.