Fix instanceof bug and starts adding tests.