Refactor ab log test logic