add simple unit tests for R; fix compile issue