Refactor buying bank insurance code

Put buying bank insurance logic in a separate function to make it more
maintenable, and made a generic buy item function. At the moment it
works for buying 1 item at a time, but we can change it in the future if
need to buy multiple items