Refactor ab test dom manipulation