Add graphics test and some refactor