fix bugs in # function, update test script