More tests and refactoring in test_spec