ABTest refactor and Bug fix