You are repeating this algorithm. Think about creating a generic method. This is test code, so I am not too concerned, though.