fixed logic of self-test