Some gfx fixes and tests

All the tests have been validated on a real Nokia Asha 503
I'll do this optimization in a followup