implemented variable elimination algorithm and added a test for it