Fix two bugs related to opencl context.

1. As getDevice will implicitly call setDevice, in getContext we should not need to call it again.
2. Fix an incorrect type casting.