Modify three testOn* functions: delete temp Gate documents after
detection, to release memory space and avoid memory leak.