Add tests to analytics and fix them