Add tests for Invalidation endpoint. Fix bugs.