Holistic methods for protecting and testing embedded devices