add test for webhook
refactor webhook endpoint