Refactored tests to use AssertQuantityEqual and AssertQuantityAlmostEqual

Also created a contextmanager to capture log outputs.