[Tests] Remove duplicate code.