moved test code to test function