In an action against an unauthorized person or nonadmitted insurer upon a contract of insurance issued or delivered in this state to a resident or to a corporation authorized to do business in this state, if the person or insurer has failed for 30 days after demand before the commencement of the action to make payment in accordance with the terms of the contract, and it appears to the court that the refusal was vexatious and without reasonable cause, the court may allow to the plaintiff a reasonable attorney fee and include the fee in the judgment that may be rendered in the action. Failure of the person or insurer to defend the action shall be considered prima facie evidence that its failure to make payment was vexatious and without reasonable cause.