added test for when-trigger functionality
implemented when-trigger