[#1349] Remove some code repetition by adding a base class