Refactored Capsule to allow for easier unit testing