Fix error while showing persistent result set in CLI

Added failing test case.
All existing tests passing.