checked truth value before pattern expansion
refactoring: adding helper methods to simplify common operations
updated head.spec and included it in regression test