extract testcode duplication