Fixing randomly failing tests in the Scala module

As described in #761, there are more than one non-bridge method generated and returned by the `getDeclaredMethods` call. In order to ensure that we retrieve the correct one, we match on the exact name, i.e. on the `apply` function.