[ticket/12597] Refactoring and test improving

Adding tests of return status
Refactoring code
Adding consistency in verbose mode

PHPBB3-12597