core: LegalMoves implementation with some unit testing