How can I test a function that has been called

You can test this much easier than you think. In your test you can simply subscribe the test process to the event that will be broadcasted and use assert_receive…sorry on mobile.