Fix testing image creation.
Improve testing if there is enough memory for subtaask on GPU.