Fixes and tests for constructor functions

This patch series fixes some constructor bugs and adds some testcases.