Refactor and Add Sample Test