Added passing GenServer tests and fixes

Fixes were quite extensive and required some refactorings.