Fixed compilation and debugged (very basic test is added)