Fixes bugs using indexes in CREATE TABLE by adding checks for table existence;
updates tests