Regression tests

Cherry picked from:
  * afccd04c59ef39d1c5800d21da2d97d83e62588f
  * 4501a55917ff25dfe5611e7b7cbdaebee1313a3f
  * fdb17265d765be18f081d7de46e1c66bf9925112
  * 9630ccf69196b74af6cce84e0bdc395e8912300f
  * 850f3c13fdb1023c25fb22f35941a0de26cbc4b7
Fix #1198
(cherry picked from commit ef07b7ecb120400fae9446183c355779030a1d09)
Implement #1175 + Unit Test
(cherry picked from commits 961c658c143ed1b98d2363108ff3eb70a9963a6e, 2becb185578626e49b749af55e9ea96580762ebd)
Fix #1024
(cherry picked from commit 6a97f4a6c608a681b5e7135b76ef8dc3c2f814c0)

Conflicts:
	ext/config.c
Fix bug #947
(cherry picked from commit c3166d9f3a483cd54afda0e0a1fe9ee2b28dba09)