Fix Sampler and add unit test for sampler, add buildprogram and releaseprogram too