add nil test, fix copyVar issue