Moved some behaviour to one place

**What does this MR do?**
It moves some duplicated behaviour to one place

**Why is this MR needed?**
Well, its just a refactoring, doesn't fix anything, although it improves CodeClimate score a little
I think you might have meant `to_s` instead of `to_string`? That should fix the test errors, too.