When you buy a house with a previous tenant on a month to month lease and they are wanting to stay, make sure you take the right steps to ensure future success.
The security deposit and prorated rent should be given to you at closing. After closing you should immediately notify the tenant in writing that you are the new owner, and address any issues they may have.
It’s normally acceptable to keep them on a month to month lease, until you are certain you want to keep them as tenants. If you want them to stay, have them sign a new lease with you. Have a written agreement with clear expectations on when/how to pay rent, take care of the rental, give notice, report maintenance, and any other general terms.
As any landlord should, educate yourself on how you will handle future problems (tenants want to break lease, no rent, late rent, noise complaints, etc.). Don’t wait until a problem occurs to figure out what to do.
Being prepared makes life a lot easier.