refactored tests to have less repeated code