Locked out of power in most of the country, Democrats on Tuesday made their seventh and eighth gains of 2017 in state legislative races. In New Hampshire, they flipped a Republican-held House seat — their third win of the year in the swing state. And in Florida, the party narrowly won a Miami-area state Senate seat with an assist from the progressive Priorities USA.

“Democrats have now won seats from the GOP eight times in just 27 chances — almost 30 percent of all special elections in Republican-held seats in the Trump era,” Daily Kos’s political editor wrote in a memo to readers Tuesday night. “What’s more, the playing field has been very hostile to Democrats: Trump won these 27 districts by an average of 19 points.”

The Florida race in particular was viewed by Democrats as a test run for upcoming races in Virginia next year and most of the country in 2018. The 40th district, which had not been competitive in years, was targeted as soon as a resignation kicked off the special election. With some trepidation, Democrats nominated Annette Taddeo, a candidate with a history of losing close races, whose 2016 run for Congress was damaged by a hack of the Democratic Congressional Campaign Committee.

“[Taddeo] has proven to be a somewhat poor fund-raiser and she has gained a reputation as an inadequate campaigner among some of the talkers in the community,” a DCCC analyst wrote in a memo that was stolen, released online and used by opponents before Taddeo lost a Democratic primary.

Some of that nervousness persisted into 2017, but the 40th was tantalizing for Democrats, offering a chance to win in a district that in 2016 chose Hillary Clinton over Donald Trump. Democrats and allies ended up spending around $3 million to help the nominee, outspent by just $500,000 by Republicans. (Priorities spent $200,000 on digital get-out-the-vote ads.) But Taddeo, who was struggling before Election Day, won the September turnout and the race.

The race was closer than the 2016 presidential election in the district, when Hillary Clinton won South Florida in a landslide. But the district lies inside one of the 23 held by Republicans and carried by Clinton. And in Virginia, where the House of Delegates is up for grabs this year, 17 Republican-held districts went for Clinton — enough, in theory, to flip control of the state’s lower house for the first time since the 1990s.