Refactor mines, extract methods and make unit test for Grid isValidCell