tests and code for check/checkmate