President Barack Obama sought to calm jittery Democrats Wednesday as they prepared to head home to face voters, assuring them they’re “on the right side of history” despite problems with the launch of his massive health care overhaul and an immigration fight with Republicans.

In back-to-back closed sessions with House and Senate Democrats, Obama delivered his broad message about economic prosperity and expanding the middle class. But in return he was confronted with questions from Democrats who are nervous about implementation of the health care law as they look ahead to town hall meetings during the August recess — and to midterm elections next year.

The meetings at the Capitol offered a rare chance for the party’s rank and file to press the president about budget talks with Republicans, the next chairman of the Federal Reserve and local jobs projects, as well as to appeal to him for help in next year’s campaigns. In a lighter moment, House Democrats presented Obama with a birthday cake. He turns 52 on Sunday.

The White House is seeking to keep up enthusiasm among Democrats following a rough start to Obama’s second term.

He has gained an agreement in the Senate to get at least some long-blocked nominees confirmed, and the Senate has passed its version of sweeping immigration legislation. But the immigration overhaul faces a deeply uncertain future in the Republican-led House, where many in the GOP oppose a path to citizenship for the estimated 11 million immigrants in the country illegally.

Obama’s landmark health care law continues to baffle many Americans, and the administration failed to assuage the public when it abruptly announced this month that it would delay a major provision requiring employers to provide coverage due to concerns about complexity.

While major provisions of the overall bill kick in Jan. 1, uninsured people will be able to start shopping for health plans on Oct. 1, and some Democrats are wary about the system being ready. Rep. Carol Shea-Porter of New Hampshire said that in her state there is not enough competition because only one company had entered into the health care exchange.

In response, Obama told House Democrats as they head back to their districts that they “are on the right side of these issues and the right side of history in terms of providing health care to Americans and to ultimately finding comprehensive immigration reform,” said Rep. Janice Hahn of California.

Said Rep. John Yarmuth of Kentucky: “I just think he was trying to bolster the courage of the group.”

Obama spoke at length about his administration’s roll-out plans for the health care exchanges, which could be critical to the health care law’s success or failure.

Sen. Angus King, an independent from Maine who caucuses with the Democrats, said Obama told senators not to be defensive when discussing the law.

“Basically he said we have to remind people that a lot of good things are happening,” King told reporters after the senators-only meeting. King listed several of what he said are the law’s accomplishments, such as children being able to use their parent’s insurance policies until age 26 and reduced costs for drugs.

King also said there needs to be more emphasis on explaining what the health care law “really means” to Americans because of repeated attempts by House Republicans “to essentially sabotage it and frighten people.”

The sessions came just days before lawmakers leave the capital for a six-week recess and the prospect of facing constituents back home at town halls at a time when polls show Congress being held in low regard.