Implement a device logic

The common device logic was implemented.
Tests are also present.