Added test cases. Made ai.vala more patch worthy.