search for thead elements and use loop to check for empty elements more efficiently

fix up tests

forgot to use np for dtype