refactoring scripting adaptors, adding unit tests