cap code and tests