add encoder signal handler and test for it