Some gfx fixes and tests

All the tests have been validated on a real Nokia Asha 503
Unfortunately I don't remember where I took this code. I've had the class in my tests directory for a while and I thought I'd add it with these other tests (even if it's unrelated to the bug being fixed)