Decouple implementation codes with test codes

Hi Daniel,

I have fixed the issues to decouple the implementation codes with test codes, Please take a look and merge it to the master.

Mike