The US Senate has avoided a government default by passing a bill to lift the debt ceiling and introduce spending cuts days before its Monday deadline.