test + fixes for startingIndex beyond contentLength