added unit tests for schema detection

fixed some issues with schema detection