Add test for variable initialization and some related fixes