add autotest and cleanup