Updated isAttacked function, lots of primitive testing

I really should implement some kind of more sophisticated unit testing
as my current approach makes it hard to discover bugs and even more
difficult to fix them.
Added checkLegal function