Added GetNumDevices method and restructured tests for better maintainability.