Adds tests, fixes contexts and return values