Decidability of logic program semantics and applications to testing