Fix mapping with multiple layer

- fix the error
- add a test with multiple mapping possibilities