Fix call vs apply bug and add a test for it