fix intermittence
add invariant
fixing tests