refactor and added tests for board rules