Fixing some canvas focusing bugs + unit tests.