percolation implementation with tests