Fix hack and simplify code for test names formatting