Refactor IpTables class to remove duplication.

This CL tries to remove as much duplicated code from the IpTables class
as possible. The basic construct of running the same command with
different executables/options is extracted into a helper function.

Moreover, the unit tests are simplified by mocking one function call
higher and removing a lot of set-up duplication.

Bug: 26911013
Change-Id: Iecdacab2ef6ffa5631c877835bdfb0bf7191536c
4 files changed