Reworked to move device type detection into separate methods.
Added tests for the assignment/