Refactor and complete the #same_credential test (2)
Remove some code offenses