Tidy up the code and align it closer with the libgdx test code.