Fix event emission and add test for unlink-oauth event