Legislation to strengthen tenants’ rights and prevent homelessness has passed Stage 1 in the Scottish Parliament.