Fix drawing on master, and add some tests.