Section 17. The commissioner may, subject to any conditions as the commissioner may prescribe, grant to an out-of-state bank, an out-of-state federal bank or a foreign bank a certificate authorizing it to act in a fiduciary capacity pursuant to chapter 167G, so far as applicable; provided, however, that such bank shall be authorized to act by the laws of the jurisdiction where its principal office is located; and provided, further, that the laws of such jurisdiction, as determined by the commissioner, shall grant a similar privilege or privileges to a bank. An out-of-state bank, out-of-state federal bank or a foreign bank holding a certificate and appointed a fiduciary shall be subject to the General Laws with respect to the appointment of agents by fiduciaries and to the same taxes, obligations and penalties, with respect to its activities as fiduciary and the property held by it in its fiduciary capacity, as banks, and no certificate shall be issued to an out-of-state bank, out-of-state federal bank or a foreign bank until it has filed with the commissioner an agreement in writing, in which it binds itself to perform said obligations and pay any such taxes and penalties as aforesaid as may be levied or imposed upon it in this commonwealth. A bank, to the extent only that it acts as fiduciary as authorized in this section, shall not be deemed to transact business in the commonwealth for the purposes of sections 40 to 42, inclusive, of chapter 167.