Add prepared test and small refactorings

Signed-off-by: Joern Bernhardt <jb@campudus.com>