Refactor unit tests to use more convenient doctest assertion macros (Part 2) (#3405)
Refactor unit tests to use more convenient doctest assertion macros (Part 2) (#3405)

* Refactor assertion and adjust expected error message

* Refactor assertion and adjust expected error message

* Refactor assertion and remove redundant local variable

* Refactor assertion and remove redundant local variable

* Rename local variable

* Apply formatting
nlohmann/json,nlohmann/json,nlohmann/json