Added guard functionality and simple tests