minmax algorithm + some related tests