Republicans have taken over Congress in the US midterm elections, following a campaign in which they focused on attacking President Obama's policies.