restructure test-code