added tests and some improvements in sample