refactor test and fix namespace bugs