Added tests for preserved keys

Added methods testPreserveKeys and testPreserveKeysScalar