In annual and final settlements, the executor, administrator, or guardian shall be entitled to credit for such reasonable sums as he may have paid for the services of an attorney in the management or in behalf of the estate, if the court be of the opinion that the services were proper and rendered in good faith. Where the executor, administrator, or guardian acts also as attorney, the court may allow such executor, administrator, or guardian credit for his reasonable compensation as attorney in lieu of his compensation as executor, administrator, or guardian.