An automated functional test and fault detection method