updated code and test scripts