Segment registers: use templates instead of macros
Segment registers: backup/restore values

This ensures the test exits cleanly.
Merge pull request #1 from Tilka/segment-registers

Fix segment register tests