Add a test and fix a bug in AMD support.