add indexExists test
bug fixed