Make analytics testing more flexible
Simplify code