Added more thorough testing, refactored quantity variable logic