Spain ends political gridlock, but tests lie ahead