added test code, main code