Fix #1047: fix platform lookup and add unit tests
8 files changed