They may take mortgages or pledges or make attachments of any property to secure the payment of debts due to them, and may perfect a title thereto by proper legal proceedings; but they shall sell or dispose of any property so obtained, which they are not authorized to hold, within 5 years after the title is perfected.