implemented in-check test. fix bug