Fixed bug with adding custom variables. Added unit test for exception when adding variables with same index.