Updated test code to new API, to avoid deprecation warning