Fix handling of case sensitive register aliases and add a test for the bug