Legislation to protect same-sex marriages advances in Senate test vote