Added some tests, corrected problems in handling castling