added tests, cleaned template and warpped up