The solution to this is simple; erase your devices before you cross an international border and carry no data storage. If the reset device was taken from you then it's been bugged go buy a replacement. Otherwise just log back in to the cloud on the other side.
Depends on the device. When they take it out of sight they'll plug it into an automated unit that just hoovers up the data and sends it to intel. They want to build a detailed profile on every traveller. Now if you wipe the device and are logged out of your accounts, they're stuck. So they leave a rootkit that relays the login info when you type it in at home later.
If they take your device out of sight or plug it into any of their hardware, then it's a write off. Straight to Craigslist