Allows invoking a method while redirecting input or output to a string