Fix dirty script detection bug