Merge "Refactored device.py and tests/device_unit_test.py." into main