Refactor spec test cases