bugfix: format happening before substitution; test refactoring