refactored code to make it one test for all 3