This isn't really a PhotoReading question.

If you've failed and you want to or need to pass that test you will have to take it again. There would be no ifs or buts about it right?

Till you know the answer you are going to be worried, part of what you are doing looks like self punishment, like you feel guilty because you might have failed. You're trying to transfer that guilt to other things. And at the same time release the stress.

When you are ready to face the fact, pass or fail, the past is the past and it's what you do now that sets the path for your future success. You will be able to get back into a better routine.

Right you are that this can become a bad habit that stays with you. Look at your motive for doing it. When you understand that
you know why you're doing it you have a choice. When you know you have a choice you can decide.

Alex